package com.hcnow.scheduled

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.messaging.simp.SimpMessagingTemplate
import org.springframework.messaging.simp.user.SimpUserRegistry
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component


@Component
class ScheduleTasks{
    @Autowired
    lateinit var messageTemplate: SimpMessagingTemplate
    @Autowired
    lateinit var userRegistry: SimpUserRegistry

    private val logger:Logger = LoggerFactory.getLogger(ScheduleTasks::class.java);

    @Scheduled(fixedRate = 3000)
    fun task1(){
//        logger.info("socket连接人数:" +  userRegistry.userCount);
//        messageTemplate.convertAndSendToUser(userRegistry.getUser("bigPlatform.1.test")?.name,"/queue/message", WebSocketMessage(Random().nextInt(100).toString()))
    }

}